<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp" %>
  <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

	<%@ include file="/WEB-INF/include/header.jsp" %>
	<%@ include file="/WEB-INF/include/submenu.jsp" %>
	
	<div class="container-fluid ms-container has-ms-sidemenu">
	
	  <ol class="ms-breadcrumb breadcrumb">
	    <li class="active">服务供方列表</li>
	  </ol>
	
	  <div class="ms-content-layout">
	
	    <div class="ms-operation-bar no-margin no-bottom-border clearfix">
	      <div class="ms-operation-group pull-right">
	
	        <a href="${ctx.host}/suppliers/search" data-target="#search" data-toggle="modal" class="btn ms-btn ms-btn-blue">
	          <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
	        </a>
	        
	        <a href="${ctx.host}/suppliers/introduce" data-target="#introduce" data-toggle="modal" class="btn ms-btn ms-btn-blue">
	          <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;创建服务供方
	        </a>
	
	      </div>
	    </div>
	
	    <table class="table table-hover ms-table">
	      <thead>
  	      <tr>
  	        <th>代码</th>
  	        <th>名称</th>
            <th>简称</th>
  	        <th>供方级别</th>
  	        <th>上级供方</th>
  	        <th>默认分区</th>
  	        <th>公司类型</th>
  	        <th>审核状态</th>
            <th>VAM使用方</th>
  	        <th class="text-center">操作</th>
  	      </tr>
	      </thead>
	
	      <tbody>
	        <c:forEach items="${suppliers}" var="supplier">
		        <tr>
		          <td>${supplier.code}</td>
		          <td>${supplier.name}</td>
              <td>${supplier.shortName}</td>
		          <td>${supplier.level.description}</td>
		          <td>
		            <c:if test="${not supplier.first}">
		              <c:forEach var="parent" items="${persist.parentSupplier(supplier)}">
		                ${parent.code} - ${parent.name}<br/>
		              </c:forEach>
		            </c:if>
		          </td>
		          <td>${supplier.branch.name}</td>
		          <td>${supplier.type.description}</td>
		          <td>${supplier.status.description}</td>
              <td>${supplier.vam ? '是' : '否'}</td>
		          <td>
		            <a href="${ctx.host}/suppliers/${supplier.id}/change-branch" data-target="#change-branch" data-toggle="modal">修改默认分区</a>&nbsp;&nbsp;
                <a href="${ctx.host}/suppliers/${supplier.id}/change-level" data-target="#change-level" data-toggle="modal">修改供方级别</a>&nbsp;&nbsp;
                <a href="${ctx.host}/suppliers/${supplier.id}/sync-shortname" data-target="#sync-shortname" data-toggle="modal">同步简称</a>&nbsp;&nbsp;
                <a href="${ctx.host}/suppliers/${supplier.id}/delete" data-target="#delete" data-toggle="modal">删除</a>&nbsp;&nbsp;
		            <c:if test="${supplier.level.second}">
		              <a href="${ctx.host}/suppliers/${supplier.id}/change-parent" data-target="#change-parent" data-toggle="modal">修改上级公司</a>
		            </c:if>
		          </td>
		        </tr>
	        </c:forEach>
	      </tbody>
	
	      <tfoot>
		      <tr>
		        <td colspan="10" class="no-vertical-padding">
		          <div class="pull-left">
		            <jsp:include page="/WEB-INF/include/page.jsp">
		              <jsp:param name="url" value="${ctx.host}/suppliers"/>
                  <jsp:param name="queryString" value="${queryString}"/>
		            </jsp:include>
		          </div>
		        </td>
		      </tr>
	      </tfoot>
	    </table>
	
	  </div>
	</div>
	
	<%@ include file="/WEB-INF/include/script.jsp" %>
	<d:resource type="script" root="${ctx.resource}/build" src="js/page/authority/organization/supplier-list.js"/>
	<script type="text/javascript">
	  require(['page/authority/organization/supplier-list'], function (page) {
	    page.init()
	  })
	</script>

</body>
</html>
